﻿<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:my="clr-namespace:CrazyKTVfromCashBox" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="CrazyKTVfromCashBox.MainWindow"
        Title="Cashbox KTV Song Toolset" Height="620" Width="780" Icon="/CashBox;component/cashbox.ico" Loaded="Window_Loaded">
    <Window.Resources>
    	<my:CrazySongDataSet x:Key="crazySongDataSet" />
    	<CollectionViewSource x:Key="ext_CashBoxViewSource" Source="{Binding ext_CashBox, Source={StaticResource crazySongDataSet}}" />
    	<CollectionViewSource x:Key="ktv_SongViewSource" Source="{Binding ktv_Song, Source={StaticResource crazySongDataSet}}" />
        <my:DataSet1 x:Key="dataSet1" />
        <CollectionViewSource x:Key="dtSearchKp2pViewSource" Source="{Binding Path=dtSearchKp2p, Source={StaticResource dataSet1}}" />
        <CollectionViewSource x:Key="dtSearchResultViewSource" Source="{Binding Path=dtSearchResult, Source={StaticResource dataSet1}}" />
    </Window.Resources>
    <Grid DataContext="{StaticResource ext_CashBoxViewSource}">
    	<Grid.RowDefinitions>
    		<RowDefinition/>
    	</Grid.RowDefinitions>
    	<VisualStateManager.VisualStateGroups>
    		<VisualStateGroup x:Name="VisualStateGroup"/>
    	</VisualStateManager.VisualStateGroups>
    	<Grid.ColumnDefinitions>
    		<ColumnDefinition/>
    		<ColumnDefinition Width="Auto"/>
    	</Grid.ColumnDefinitions>
        <TabControl HorizontalAlignment="Stretch" x:Name="tabControl1" VerticalAlignment="Stretch">
            <TabItem Header="new songs" x:Name="tabItem1">
               
                    <Grid Margin="0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                        <ColumnDefinition Width="150"/>
                    </Grid.ColumnDefinitions>
                        <Grid Grid.Column="0" Margin="10">


                        <Label Content="From" Height="28" HorizontalAlignment="Left" Margin="17,15,0,0" x:Name="label1_1" VerticalAlignment="Top" Width="49" />
                        <DatePicker Height="25" HorizontalAlignment="Left" Margin="100,15,0,0" x:Name="datePicker1" VerticalAlignment="Top" Width="151" />
                            <DatePicker Height="25" HorizontalAlignment="Left" Margin="100,46,0,0" x:Name="datePicker2" VerticalAlignment="Top" Width="151" />
                            <Label Content="To" Height="28" HorizontalAlignment="Left" Margin="17,46,0,0" x:Name="label1" VerticalAlignment="Top" Width="49" />
<Button Content="Download Cashbox new song list" Height="30" HorizontalAlignment="Left" Margin="32,89,0,0" x:Name="button2" VerticalAlignment="Top" Click="button2_Click" RenderTransformOrigin="0.5,0.5" d:LayoutOverrides="HorizontalAlignment" Width="219">
                                
                            </Button>
                            
                        </Grid>

                    <Grid Grid.Column="1">
                        <TextBlock TextWrapping="Wrap">
                            使用方式: <LineBreak/>         <LineBreak/>                
                            1. 選要開始下載歌曲列單的啟始日期<LineBreak/><LineBreak/> 
                            2. 選結束日期<LineBreak/><LineBreak/> 
                            3. 按 "Download Cashbox new song list"<LineBreak/><LineBreak/> 
                            4. 按完按鍵,此程式可能會無反應一段時間,因為在連網路下載,請不要硬結束,除非等了超過一個小時.<LineBreak/>
                            
                        <TextBlock.Background><LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"><GradientStop Color="#FF2E67AA" Offset="1" /><GradientStop Color="White" Offset="0" /></LinearGradientBrush></TextBlock.Background></TextBlock>
                    </Grid>
                </Grid>
                    
                
            </TabItem> 
            <TabItem Header="download songs">
                <Grid>
                    <Grid Margin="0,0,150,0" Height="45" VerticalAlignment="Top">
                        <Label Content="Search for:" HorizontalAlignment="Left" Margin="13.27,9,0,0" VerticalAlignment="Top"/>
                        <ComboBox SelectedValuePath="Tag" Height="23" HorizontalAlignment="Left" Margin="88,9,0,0" x:Name="comboBox1" VerticalAlignment="Top" Width="120" SelectionChanged="comboBox1_SelectionChanged" d:LayoutOverrides="HorizontalAlignment">
                    		<ComboBoxItem Content="Song Name" IsSelected="True" Tag="1"/>
                    		<ComboBoxItem Content="Singer Name" Tag="2" />
                    	</ComboBox>
                        <TextBox Height="23" Margin="214,9,0,0" x:Name="textBox2" VerticalAlignment="Top" PreviewKeyDown="textBox2_PreviewKeyDown" HorizontalAlignment="Left" Width="168" VerticalContentAlignment="Top" Visibility="Hidden" />
                        <Button Content="Load File into Below" Height="23" HorizontalAlignment="Left" Margin="440,9,0,0" Name="button6" VerticalAlignment="Top" Width="137" Click="button6_Click" Background="#FFFFF396" />
                    </Grid>
                    <Grid Margin="0,45,150,50">
                        <DataGrid AutoGenerateColumns="False" EnableRowVirtualization="True" HorizontalAlignment="Stretch" ItemsSource="{Binding Source={StaticResource dtSearchResultViewSource}}" Margin="0" Name="dtSearchResultDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" VerticalAlignment="Stretch" SelectionUnit="CellOrRowHeader">
                            <DataGrid.Columns>
                                <DataGridTextColumn Binding="{Binding Path=rownum}" Header="" />
                                <DataGridTextColumn x:Name="songTitleColumn" Binding="{Binding Path=songTitle}" Header="Title" />
                                <DataGridTextColumn x:Name="songSingerColumn" Binding="{Binding Path=songSinger}" Header="Singer" />
                                <DataGridTextColumn x:Name="kp2pColumn1" Binding="{Binding Path=kp2p}" Header="KP2P Link" Width="SizeToHeader" MinWidth="200" />
                                <DataGridTextColumn x:Name="fileTypeColumn" Binding="{Binding Path=fileType}" Header="Type" Width="SizeToHeader" />
                                <DataGridTextColumn x:Name="fileSizeColumn" Binding="{Binding Path=fileSize}" Header="Size" Width="SizeToHeader" />
                                <DataGridTextColumn x:Name="songLanguageColumn" Binding="{Binding Path=songLanguage}" Header="Lang" Width="SizeToHeader" />
                                <DataGridTextColumn x:Name="songIDColumn" Binding="{Binding Path=songID}" Header="song ID" Width="SizeToHeader" />
                            </DataGrid.Columns>
                        </DataGrid>

                        <DataGrid AutoGenerateColumns="False" EnableRowVirtualization="True" ItemsSource="{Binding Source={StaticResource dtSearchKp2pViewSource}}" x:Name="dtSearchKp2pDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" DataContext="{Binding}" SelectionUnit="CellOrRowHeader" ClipToBounds="False" HorizontalAlignment="Stretch">
                    		<DataGrid.Columns>
                    			<DataGridTextColumn x:Name="searchForColumn" Binding="{Binding searchFor}" Header="Song Name" Width="200" PastingCellClipboardContent="searchForColumn_PastingCellClipboardContent" CopyingCellClipboardContent="searchForColumn_CopyingCellClipboardContent" />
                    			<DataGridTextColumn x:Name="singerColumn" Binding="{Binding singer}" Header="singer" Width="SizeToCells" Visibility="Hidden" />
                    			<DataGridTextColumn x:Name="songColumn" Binding="{Binding song}" Header="Song" Width="SizeToCells" Visibility="Hidden" />
                    			<DataGridTextColumn x:Name="kp2pColumn" Binding="{Binding kp2p}" Header="Kp2p" Width="250" CanUserReorder="False" CanUserSort="False" Visibility="Hidden" Selector.IsSelected="True" IsReadOnly="True" />
                    		</DataGrid.Columns>
                    	</DataGrid>
                     </Grid>
                    <Grid Margin="0" Width="150" HorizontalAlignment="Right">
                    	<Grid.Background>
                    		<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    			<GradientStop Color="White" Offset="0"/>
                    			<GradientStop Color="#FF9F9FEF" Offset="1"/>
                    		</LinearGradientBrush>
                    	</Grid.Background>
                        <TextBlock Margin="0" TextWrapping="Wrap"><TextBlock.Background><LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"><GradientStop Color="#FF2E67AA" Offset="1" /><GradientStop Color="White" Offset="0" /></LinearGradientBrush></TextBlock.Background>
                            使用方式:<LineBreak /><LineBreak />
                            1. 選要搜尋種類,歌曲名稱或者是歌者<LineBreak /><LineBreak />
                            2. 到下面的表格,連點兩下就可以填寫,一直到寫完要搜尋的資料,點下面的"Get Kp2p Link" 按鈕, 這會花一段時間,請耐心等候,如果歌者很多歌的話,有可能一個小時,也要看連線速度<LineBreak /><LineBreak />
                            3. 結果出現後,會出現 Kp2p的欄位,將全部或點選(SHIFT)你要的 copy (Ctrl + C)起來<LineBreak /><LineBreak />
                            4. 啟動, 按<Hyperlink Click="Hyperlink_Click" NavigateUri="http://cid-682b6f9bad169941.office.live.com/self.aspx/CrazyKTV^_print/MtvP2P.zip">MTVp2p軟體</Hyperlink> 上面"歌庫, 下載, 分享" 的 "下載" -> "新建" 將剛剛 copy 過來的 貼上 (Ctrl + v) 去<LineBreak /><LineBreak />
                            5. 如果你遇到下載後為亂碼的問題,<Hyperlink Click="Hyperlink_Click" NavigateUri="http://www.youtube.com/watch?v=G_XE_lloOyY">可以試試 convertz 也很方便的快速自動更改檔案名</Hyperlink><LineBreak /><LineBreak />
                            6. 大量導入,請點"Load File into Below", 然後開啟 "~test.txt" 為範例<LineBreak />
                        </TextBlock>

                        
                    </Grid>
                    <Grid Height="50" x:Name="grid1" VerticalAlignment="Bottom" Margin="0,0,150,0">
                    	<Button Content="Get Kp2p Link" x:Name="button4" Click="button4_Click" Margin="104,9,0,18" HorizontalAlignment="Left" Width="139" VerticalContentAlignment="Top" />
                    	<Button Content="Clear Search" HorizontalAlignment="Right" Margin="0,10,163,0" x:Name="button5" Width="141" Click="button5_Click" VerticalAlignment="Top" VerticalContentAlignment="Top" Height="23" />
                    </Grid>
                </Grid>
                
            </TabItem>
            <TabItem Header="all songs" Width="67.2133333333333">
                <Grid>
                    
                    
                    
                	<Grid.ColumnDefinitions>
                		<ColumnDefinition/>
                        <ColumnDefinition Width="150"/>
                    </Grid.ColumnDefinitions>
                    <Grid Grid.Column="0" Grid.RowSpan="2">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="70" />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="120" />
                                <ColumnDefinition Width="175" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Button Content="Download all Songbook" HorizontalAlignment="Stretch" Margin="2,4,0,0" x:Name="button1" VerticalAlignment="Top" Click="button1_Click" Grid.Column="1" d:LayoutOverrides="HorizontalAlignment" ToolTip="This feature is only enabled if you have CrazySong.mdb in the same folder." Height="35" />
                            <Button Content="Cancel downloading" HorizontalAlignment="Stretch" Margin="2,39,0,0" x:Name="button3" VerticalAlignment="Stretch" Visibility="Hidden" Click="button3_Click" Grid.Column="1" d:LayoutOverrides="HorizontalAlignment" />
                            <TextBox Height="23" HorizontalAlignment="Left" Margin="62,11,0,0" x:Name="textBox1" VerticalAlignment="Top" Width="54" Text="1937" HorizontalContentAlignment="Left" />
                            <Label Content="Page 1 to:" Height="28" Margin="0,9,0,0" x:Name="label2" VerticalAlignment="Top" d:LayoutOverrides="Width" HorizontalAlignment="Left" Width="72" />
                            <TextBlock HorizontalAlignment="Stretch" x:Name="textBlock1" Text="Caution: Download could take up to 1 hours if all pages!   The list will be save to ext_cashbox table in the crazysong.mdb" VerticalAlignment="Stretch" TextWrapping="Wrap" FontWeight="Normal" Foreground="#FFDB3030" Grid.Column="2" Margin="10,10,0,0" />
                            </Grid>
                        <Grid Grid.Row="1"> 
                            <DataGrid AutoGenerateColumns="False" EnableRowVirtualization="True" HorizontalAlignment="Stretch" ItemsSource="{Binding}" x:Name="ext_CashBoxDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" VerticalAlignment="Stretch" IsEnabled="True" IsReadOnly="True" d:LayoutOverrides="GridBox" RenderTransformOrigin="0.5,0.5">
                            <DataGrid.Background>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="Black" Offset="0"/>
                                    <GradientStop Offset="1" Color="#FFF8B82E"/>
                                    <GradientStop Color="#FEF7F4F1"/>
                                </LinearGradientBrush>
                            </DataGrid.Background>
                            <DataGrid.Columns>
                                <DataGridTextColumn x:Name="cashbox_idColumn" Binding="{Binding cashbox_id}" Header="cashbox id" Width="SizeToHeader" />
                                <DataGridTextColumn x:Name="song_langColumn" Binding="{Binding song_lang}" Header="song lang" Width="SizeToHeader" />
                                <DataGridTextColumn x:Name="song_nameColumn" Binding="{Binding song_name}" Header="song name" Width="SizeToCells" />
                                <DataGridTextColumn x:Name="singer_nameColumn" Binding="{Binding singer_name}" Header="singer name" Width="SizeToCells" />
                                <DataGridTemplateColumn x:Name="createDateColumn" Header="create Date" Width="SizeToCells">
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <DatePicker SelectedDate="{Binding createDate, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" />
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>
                            </DataGrid.Columns>
                        </DataGrid>
                         </Grid>
                       
                      
                    </Grid>

                    <Grid Grid.Column="1"  Margin="0,0,0,0">
                        <Grid.Background>
                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                <GradientStop Color="#FF2E67AA" Offset="1" />
                                <GradientStop Color="White" Offset="0" />
                            </LinearGradientBrush>
                        </Grid.Background>
                        <TextBlock TextWrapping="Wrap" >
                            使用方式: <LineBreak/>         <LineBreak/>                
                            1. 先去<Hyperlink Name="hl2" RequestNavigate="HandleRequestNavigate" NavigateUri="http://www.cashboxparty.com/mysong/mysong_search_r.asp">錢櫃網站</Hyperlink>看目前共有幾頁 (目前是1937頁) (當然可以多設,但是會花更多時間跑)<LineBreak/><LineBreak/> 
                            2. 填你要下載幾頁的歌曲<LineBreak/><LineBreak/> 
                            3. 按 "Download all song book"<LineBreak/><LineBreak/> 
                            4. 按完按鍵,此程式可能會無反應一段時間,因為在連網路下載,請不要硬結束,除非等了超過兩個個小時.<LineBreak/>
                            <LineBreak/>
                            <LineBreak/>
                            * 此功能需要 CrazySong.mdb 在與此程式的同一個檔案夾裏面,因為會將資料寫入,如果沒有的話,將無法使用次功能
                        </TextBlock>
                    </Grid>


                </Grid>
                
                
                
            </TabItem>
          

            <TabItem Header="About">
                <Grid>
                	<Grid.Background>
                		<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                			<GradientStop Color="White" Offset="0"/>
                			<GradientStop Color="#FF2E67AA" Offset="1"/>
                		</LinearGradientBrush>
                	</Grid.Background>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid Grid.Column="0">
						<TextBlock Name="textBlock2" VerticalAlignment="Center" TextWrapping="Wrap" HorizontalAlignment="Center" Margin="50" >
                            This is created by Bob ChengYu Yang. Please contact me if you have any questions. have a fun time with this and your KTV system. :-)    <LineBreak/> <LineBreak/>  
                            如果您知道任何 KTV的搜尋網站,或下載網站,請告知,我可以嘗試加入,謝謝<LineBreak/><LineBreak/>
                        <Hyperlink Name="hl3"  RequestNavigate="HandleRequestNavigate3"  NavigateUri="mailto:bobyang03@hotmail.com" TargetName="_blank">bobyang03@hotmail.com</Hyperlink>
                        </TextBlock>
                    </Grid>
                 </Grid>
            </TabItem>
            
        </TabControl>
     </Grid>
</Window>
